home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks95
/
Aaron 1.0b3.sit
/
Aaron 1.0b3
/
Aaron Source
/
CDEF and Patches
/
CDEF.c
next >
Wrap
Text File
|
1995-06-24
|
8KB
|
286 lines
/* Aaron © 1995 Gregory D. Landweber, ALL RIGHTS RESERVED */
#include "CDEF.h"
#ifndef __powerc
#include <A4Stuff.h>
#endif
/*Boolean UseTinges ( RGBColor theColors[] )
{
return ( Color2Index( theColors + iTingeLight ) !=
Color2Index( theColors + iTingeDark ) ) &&
( Color2Index( theColors + iHiliteLight) !=
Color2Index( theColors + iEmbossed ) );
}
void PrepareColors ( ControlHandle theControl, RGBColor theColors[] )
{
AuxCtlHandle acHndl;
CCTabHandle theTable;
short index;
Byte colorValues[9][3] = { { cBodyColor, cFrameColor, 0 },
{ cBodyColor, cFrameColor, 1 },
{ cBodyColor, cFrameColor, 3 },
{ cBodyColor, cFrameColor, 9 },
{ cBodyColor, cFrameColor, 13 },
{ cBodyColor, cFrameColor, 15 },
{ cBodyColor, cTextColor, 15 },
{ cTingeLight, cTingeDark, 0 },
{ cTingeLight, cTingeDark, 4 } };
GetAuxCtl ( theControl, &acHndl);
theTable = (*acHndl)->acCTable;
for ( index = 0; index <= 6; index++ )
GetRGBColor ( theTable, theColors + index, colorValues[index][0], colorValues[index][1], colorValues[index][2] );
// Get tinges from default "cctb"
GetAuxCtl ( nil, &acHndl);
theTable = (*acHndl)->acCTable;
for ( index = 7; index <= 8; index++ )
GetRGBColor ( theTable, theColors + index, colorValues[index][0], colorValues[index][1], colorValues[index][2] );
}
*/
void GetPartColor ( CTabPtr theTable, RGBColor *theColor, short part )
{
short temp = (theTable)->ctSize;
while ( ( (theTable)->ctTable[temp].value != part ) && temp-- );
if ( temp < 0 )
temp = 0;
*theColor = (theTable)->ctTable[temp].rgb;
}
/*
void GetRGBColor ( CCTabHandle theTable, RGBColor *theColor, short backPart, short forePart, short shade)
{
RGBColor foreColor, backColor;
GetPartColor ( (CTabPtr)*theTable, &foreColor, forePart );
GetPartColor ( (CTabPtr)*theTable, &backColor, backPart );
theColor->red = ( (long)foreColor.red - (long)backColor.red ) * shade / 15 + backColor.red;
theColor->green = ( (long)foreColor.green - (long)backColor.green ) * shade / 15 + backColor.green;
theColor->blue = ( (long)foreColor.blue - (long)backColor.blue ) * shade / 15 + backColor.blue;
}
*/
void DoDraw1 ( GregInfo *theInfo, CGrafPtr savePort, CGrafPtr myPort, Boolean onScreen )
{
short saveFont, saveSize, saveFace, saveMode;
RGBColor theForeColor, theBackColor;
PenState thePenState;
RgnHandle theRgn;
short depth;
DeviceLoopDrawingUPP drawingProc;
saveFont = myPort->txFont; saveSize = myPort->txSize;
saveFace = myPort->txFace; saveMode = myPort->txMode;
GetForeColor (&theForeColor); GetBackColor (&theBackColor);
GetPenState (&thePenState);
if ( theInfo->useSysFont ) {
TextFont (systemFont);
TextSize (0);
TextFace (0);
}
else {
TextFont (savePort->txFont);
TextSize (savePort->txSize);
TextFace (savePort->txFace);
}
PenNormal ();
RectRgn( theRgn = NewRgn(), &theInfo->theRect );
if ( onScreen ) {
if ( theInfo->pushButton )
drawingProc = NewDeviceLoopDrawingProc ( &DrawButton );
else
drawingProc = NewDeviceLoopDrawingProc ( &DrawIcon );
DeviceLoop ( theRgn, drawingProc, (long)theInfo, 0 );
DisposeRoutineDescriptor ( drawingProc );
}
else {
if ( (savePort->portVersion & 0xC000) == 0xC000 )
depth = (*savePort->portPixMap)->pixelSize;
else
depth = 1;
if ( theInfo->pushButton )
DrawButton ( depth, 0, nil, theInfo );
else
DrawIcon ( depth, 0, nil, theInfo );
}
DisposeRgn( theRgn );
TextFont (saveFont); TextSize (saveSize);
TextFace (saveFace); TextMode (saveMode);
RGBForeColor (&theForeColor); RGBBackColor (&theBackColor);
SetPenState (&thePenState);
}
void DoDraw ( GregInfo *theInfo )
{
Boolean colorPort, onScreen;
CGrafPtr savePort, wPort;
Ptr BaseAddr;
Point globalPt;
RgnHandle newClip, oldClip;
CQDProcs newProcs;
CQDProcsPtr saveProcs;
long *new, *old;
short temp;
long lRefCon;
short editField;
TEHandle textH;
// short pnVisSave;
StringPtr curApName = LMGetCurApName();
// SetPort ( (*theInfo->theControl)->contrlOwner );
GetPort ( (GrafPtr *)&savePort );
colorPort = ( (savePort->portVersion & 0xC000) == 0xC000 );
if ( savePort->rgnSave ) {
if ( theInfo->pushButton )
FrameRoundRect ( &theInfo->theRect, Radius, Radius );
else
FrameRect ( &theInfo->theRect );
return;
}
if ( ( ((long *)curApName)[1] != 'Edit' )
&& !RectInRgn (&theInfo->theRect, savePort->visRgn) ) {
return;
}
BaseAddr = ((GrafPtr)savePort)->portBits.baseAddr;
if ( colorPort )
BaseAddr = (*(PixMapHandle)BaseAddr)->baseAddr;
onScreen = ( BaseAddr == LMGetScrnBase() );
if ( /* savePort->picSave || */ colorPort || !onScreen )
DoDraw1 ( theInfo, savePort, savePort, onScreen );
else {
SetPt ( &globalPt, 0, 0 );
LocalToGlobal ( &globalPt );
OffsetRect ( &theInfo->theRect, globalPt.h, globalPt.v );
SectRgn ( savePort->visRgn, savePort->clipRgn, newClip = NewRgn() );
OffsetRgn ( newClip, globalPt.h, globalPt.v );
GetCWMgrPort ( &wPort );
SetPort ( (GrafPtr)wPort );
GetClip ( oldClip = NewRgn() );
SetClip ( newClip );
old = (long *)savePort->grafProcs;
if ( old ) {
textH = ((DialogPeek)wPort)->textH;
((DialogPeek)wPort)->textH = ((DialogPeek)savePort)->textH;
editField = ((DialogPeek)wPort)->editField;
((DialogPeek)wPort)->editField = ((DialogPeek)savePort)->editField;
SetStdCProcs ( &newProcs );
saveProcs = wPort->grafProcs;
new = (long *)&newProcs;
for ( temp = 0; temp <= 12; temp++ )
if ( old[temp] )
new[temp] = old[temp];
wPort->grafProcs = &newProcs;
lRefCon = GetWRefCon ( (WindowPtr)wPort );
SetWRefCon ( (WindowPtr)wPort, GetWRefCon ( (WindowPtr)savePort ) );
}
// pnVisSave = wPort->pnVis;
// wPort->pnVis = savePort->pnVis;
DoDraw1 ( theInfo, savePort, wPort, onScreen );
// wPort->pnVis = pnVisSave;
if ( old ) {
((DialogPeek)wPort)->textH = textH;
((DialogPeek)wPort)->editField = editField;
wPort->grafProcs = saveProcs;
SetWRefCon ( (WindowPtr)wPort, lRefCon );
}
SetClip ( oldClip );
DisposeRgn ( oldClip );
DisposeRgn ( newClip );
SetPort ( (GrafPtr)savePort );
}
}
pascal long main ( short varCode, ControlHandle theControl, short msgCode, long msgParam )
{
GregInfo theInfo;
long result = 0;
Boolean newFolder;
#ifndef __powerc
long oldA4 = SetCurrentA4();
#endif
if ( varCode >= 16 ) {
newFolder = true;
varCode -= 16;
}
else
newFolder = false;
SetResLoad ( true ); // Since FAXstf leaves this set to false
theInfo.newFolder = newFolder;
theInfo.theControl = theControl;
theInfo.msgParam = msgParam;
theInfo.inActive = (*theControl)->contrlHilite == 255;
if ( theInfo.inActive )
theInfo.pushed = 0;
else
theInfo.pushed = (*theControl)->contrlHilite != inNone;
theInfo.theRect = (*theControl)->contrlRect;
theInfo.pushButton = (varCode & 0x0007) == pushButProc;
theInfo.radio = (varCode & 0x0007) == radioButProc;
theInfo.useSysFont = !(varCode & useWFont);
switch ( msgCode ) {
case drawCntl:
if ( (*theControl)->contrlVis ) {
// PrepareColors ( theControl, theInfo.theColors );
theInfo.prefs = (GrEGHandle) GetResource ( 'GrEG', 128 );
DoDraw ( &theInfo );
}
break;
case testCntl:
if ( !theInfo.inActive && PtInRect ( *(Point *)&msgParam, &theInfo.theRect ) )
result = theInfo.pushButton ? inButton : inCheckBox;
else
result = inNone;
break;
case calcCRgns:
msgParam = msgParam & AddrMask;
case calcCntlRgn:
case calcThumbRgn:
if ( theInfo.pushButton ) {
OpenRgn ();
FrameRoundRect ( &theInfo.theRect, Radius, Radius );
CloseRgn ( (RgnHandle) msgParam );
}
else
RectRgn( (RgnHandle) msgParam, &theInfo.theRect );
break;
case initCntl:
case dispCntl:
case posCntl:
case thumbCntl:
case dragCntl:
case autoTrack:
break;
}
#ifndef __powerc
SetA4 ( oldA4 );
#endif
return result;
}